import { useCallback, useState } from 'react';

/**
 * 用于在各类 hooks 特别是 useEffect 的 deps 中，帮助强制状态改变从而触发函数重新执行
 */
export function useRefreshCount() {
  const [refreshCount, setState] = useState(0);
  const refresh = useCallback(() => {
    setState(v => (v + 1));
  }, []);
  return [refreshCount, refresh];
}

export default useRefreshCount;
